<template>
	<view class="getinstall">
		<!-- <view class="header-top" :style="{height: top+'px'}">
		
		</view> -->
		<!-- <view class="header-zhong" :style="{height: top+'px'}"> 
			
		</view> -->
		<!-- <view class="header-line" >
			<view class="left" @click="shang">
				<u-icon name="arrow-left" size="17px" color="#ffffff" />
			</view>
		
			<view class="right" style="text-align: center;">
				<view class="search">
					设置
				</view>
			</view>
		
		</view> -->
		<!-- <view class="box" :style="{height:'10'+'px'}">
		
		</view> -->
		<!-- <view class="getinstall_top">
			
		</view> -->
		<view class="getinstall_top_bottom">
			<view class="getinstall_top_bottom_a">
				<!-- <view class="getinstall_top_bottom_b">
					<view class="getinstall_top_bottom_left">
						<image class="img" src="../../static/img/xxtz.png"></image>
					</view>
					<view class="getinstall_top_bottom_zhong">
						<text class="text1">消息通知</text>
						<text class="text2">打开通知，有消息第一时间通知你</text>
					</view>
					<switch class="switch" :checked="false" style="transform:scale(0.9)" color="#FFCC33"
						@change="switch1Change" />
				</view> -->
				<!-- <view class="getinstall_top_bottom_c" >
					<view class="getinstall_top_bottom_left">
						<image class="img" src="../../static/img/yytx.png"></image>
						<text class="text">语音提醒</text>
					</view>
					<view class="getinstall_top_bottom_right">
						<u-icon class="icon" name="arrow-right" />
					</view>
				</view> -->
				<view class="getinstall_top_bottom_c" @click="bindwx">
					<view class="getinstall_top_bottom_left">
						<image class="img" src="../../static/img/bdwx.png"></image>
						<text class="text">绑定微信</text>
					</view>
					<view class="getinstall_top_bottom_right">
						<u-icon class="icon" name="arrow-right" />
					</view>
				</view>
				<!-- <view class="getinstall_top_bottom_c" @click="agreement">
					<view class="getinstall_top_bottom_left">
						<image class="img" src="../../static/img/fwxy.png"></image>
						<text class="text">服务协议</text>
					</view>
					<view class="getinstall_top_bottom_right">
						<van-icon class="icon" name="arrow" />
					</view>
				</view>
				<view class="getinstall_top_bottom_c">
					<view class="getinstall_top_bottom_left">
						<image class="img" src="../../static/img/yszc.png"></image>
						<text class="text">隐私政策</text>
					</view>
					<view class="getinstall_top_bottom_right">
						<van-icon class="icon" name="arrow" />
					</view>
				</view> -->
			</view>
			<view class="tuichu" @click="retreat">
				退出登录
			</view>
		</view>
		<!-- <van-overlay :show="getinstallshow" :lock-scroll="true">
			<view>
				<view>

				</view>
			</view>
		</van-overlay> -->
	</view>
</template>

<script>
	import homeServices from '../../service/homeService'
	export default {
		data() {
			return {
				getinstallshow: false
				// right: '',
				// padding: '',
				// top: '',
				// height: ''
			}
		},
		methods: {
			switch1Change() {

			},
			bindwx(){
				uni.login({
					provider: 'weixin',
					onlyAuthorize:true,
					success: loginRes => {
						this.code = loginRes.code
						// console.log(this.code);
						this.connectwx()
					}
				});
			},
			async connectwx(){
				// console.log(this.code);
				let params = {
					code: this.code,
				}
				let a = JSON.stringify(params)
				console.log(a);
				let res = await homeServices.bindwx(a)
				if(res.status == 200){
					uni.showToast({
						title:res.msg,
						icon:'none',
						duration:1500
					})
				}
			},
			// 退出
			async retreat() {
				let params = {}
				let res = await homeServices.retreat(params)
				uni.showModal({
					title: '提示',
					content: '确认退出登录吗？',
					confirmText:'确定',
					cancelText:'取消',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							uni.removeStorage({
								key: 'token',
								success: function() {
									console.log('success');
									uni.reLaunch({
										url: '/pages/login/login'
									})
								},
								
							})
						} else if (res.cancel) {
							return
						}
					}

				})
				// state.token=''

				console.log(res)
			},
			agreement() {
				this.getinstallshow = true
			},
			// shang() {
			// 	console.log(123)
			// 	uni.switchTab({
			// 		url: '/pages/my/my'
			// 	})
			// }
		},
		onLoad() {
			
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/sass/getinstall.scss'
</style>
